#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/12/9 09:58|09:58
# @Author  : yangdingyi
# @File    : Pow(x, n)
# @Software: PyCharm


class Solution:
    def myPow(self, x: float, n: int) -> float:

        def work(x: float, n: int):
            if n == 1:
                return x
            if n == 0:
                return 1.0
            return work(x, n % 2) * (work(x, n//2) ** 2)
        x = x if n >= 0 else 1/x
        n = n if n >= 0 else -n
        return work(x, n)


solve = Solution()
x = 2.00000
n = -10
print(x, n)
print(solve.myPow(x, n))
